package Database;

import java.sql.SQLException;
import java.util.Date;

import network.NetworkPlayer;

public class PlayerPlayedGames {
	private long gameID;
	private long userID;
	private Date gameDate;
	private String username;
	private int rating;
	private boolean winner;
	
	public PlayerPlayedGames(Long gameID, Date gameDate, Long userID, int rating, boolean winner){
		this.gameID=gameID;
		this.gameDate=gameDate;
		this.userID=userID;
		this.rating=rating;
		this.winner=winner;
	}
	
	public PlayerPlayedGames(Long gameID, Date gameDate, String username, int rating, boolean winner){
		this.gameID=gameID;
		this.gameDate=gameDate;
		this.username=username;
		this.rating=rating;
		this.winner=winner;
	}
	
	public PlayerPlayedGames(Date gameDate, String username, int rating, boolean winner){
		this.gameDate=gameDate;
		this.username=username;
		this.rating=rating;
		this.winner=winner;
	}
	
	public PlayerPlayedGames(NetworkPlayer player, boolean winner) throws ClassNotFoundException, SQLException {
		UserInfo info = DBActions.getUserInfo(player.getName());
		this.gameDate = new Date();
		this.username = player.getName();
		this.rating = info.getScore();
		this.winner = winner;
		this.userID = info.getID();
	}

	public void setGameDate(Date gameDate) {
		this.gameDate = gameDate;
	}
	
	public Date getGameDate() {
		return gameDate;
	}
	
	public void setUsername(String username) {
		this.username = username;
	}
	
	public String getUsername() {
		return username;
	}
	
	public void setRating(int rating) {
		this.rating = rating;
	}
	
	public int getRating() {
		return rating;
	}
	
	public void setWinner(boolean winner) {
		this.winner = winner;
	}
	
	public boolean isWinner() {
		return winner;
	}
	
	/**
	 * @param gameID the gameID to set
	 */
	public void setGameID(long gameID) {
		this.gameID = gameID;
	}
	
	/**
	 * @return the gameID
	 */
	public long getGameID() {
		return gameID;
	}
	
	/**
	 * @param userID the userID to set
	 */
	public void setUserID(long userID) {
		this.userID = userID;
	}
	
	/**
	 * @return the userID
	 */
	public long getUserID() {
		return userID;
	}
}
